package com.sf.algo.shortpath;

public class Node implements Comparable<Node>{
	private Coord coord;
	private Node parent;
	private int g;
	private int h;
	
	public Node(Coord coord, Node parent, int g, int h) {
		super();
		this.coord = coord;
		this.parent = parent;
		this.g = g;
		this.h = h;
	}
	public Node(int x, int y)
    {
        this.coord = new Coord(x, y);
    }
	public Node(Coord coord) {
		this.coord = coord;
	}
	@Override
	public int compareTo(Node o) {
		if (o == null) return -1;
        if (g + h > o.g + o.h)
            return 1;
        else if (g + h < o.g + o.h) return -1;
        return 0;
	}
	public Coord getCoord() {
		return coord;
	}
	public void setCoord(Coord coord) {
		this.coord = coord;
	}
	public Node getParent() {
		return parent;
	}
	public void setParent(Node parent) {
		this.parent = parent;
	}
	public int getG() {
		return g;
	}
	public void setG(int g) {
		this.g = g;
	}
	public int getH() {
		return h;
	}
	public void setH(int h) {
		this.h = h;
	}
	@Override
	public String toString() {
		return "Node [coord=" + coord + "]";
	}
	

}
